import request from '@/utils/request'
import {SERVICE_URL} from '@/config/index.js'

//  分页获取用户优惠券
export function getCouponPage (data) {
	return request.get({
		url: SERVICE_URL + '/v1/trade/discount-card-detail/index',
		data
	})
}

//  获取用户全部优惠券
export function getCouponList (data) {
	return request.get({
		url: SERVICE_URL + '/v1/trade/discount-card-detail/list',
		data
	})
}

//  创建策略订单
export function createOrder (data) {
	return request.post({
		url: SERVICE_URL + '/v1/trade/order/add',
		data
	})
}
//首单免费接口
export function freeOrder (data) {
	return request.get({
		url: SERVICE_URL + '/v1/trade/order/free-order',
		data
	})
}

// 192.168.1.2:8070/api/v1/aLiPayConfig,
export function aLiPayConfig (data) {
	return request.get({
		url: 'http://192.168.1.2:8070/api/v1/aLiPayConfig',
		data
	})
}
export function weChatPayConfig (data) {
	return request.get({
		url: 'http://192.168.1.3:8070/api/v1/weChatPayConfig?order=123&money=123',
		data
	})
}
//  订阅策略
export function subscribePage (data) {
	return request.get({
		url: SERVICE_URL + '/v1/trade/order/subscribe-page',
		data
	})
}

//  获取支付sdk
export function getPaySdk (data) {
	let appid = 'HBuilder'
	// #ifdef APP-PLUS
	appid = plus.runtime.appid
	// #endif
	return new Promise((res) => {
		uni.request({
			url: 'https://demo.dcloud.net.cn/payment/',
			data: { appid, ...data },
			success: (result) => {
				res(result)
			},
			fail: (e) => {
				res(e)
			}
		})
	})
}

